<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :model="keyword" :inline="true">
				<el-form-item>
					<el-input v-model="keyword" placeholder="关键字"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="warning" v-on:click="getTableData">查询</el-button>
				</el-form-item>
			
			</el-form>
		</el-col>

		<!--列表v-loading="listLoading"-->
		<el-table border :data="tableDatas" v-loading="listLoading"
				  highlight-current-row style="width: 100%;">

		
			<el-table-column type="index" width="70" label="序号" fixed="left">
			</el-table-column>
			<el-table-column prop="name" label="权限名称" width="220" fixed="left">
			</el-table-column>
			<el-table-column prop="url" label="权限接口地址" width="280" sortable>
			</el-table-column>
			<el-table-column prop="descs" label="权限描述" width="280">
			</el-table-column>
			<el-table-column prop="sn" label="权限编码">
			</el-table-column>
		</el-table>
		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
						   :page-sizes="[5, 10, 50]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
						   :total="totals" style="float:right;">
			</el-pagination>
		</el-col>

	</section>
</template>

<script>

export default {
	data() {
		return {		
			listLoading: false,
			//查询对象
			keyword: null,
			totals: 0,//总记录条数
			currentPage: 1,//当前页,要传递到后台的
			pageSize: 5, //每页显示多少条
			tableDatas: [], //当前页数据
		}
	},
	methods: {
		//选择第几页时触发
		handleCurrentChange(curentPage) {
			this.currentPage = curentPage;
			this.getTableData();
		},
		//选择每页显示记录条数
		handleSizeChange(pageSize) {
			this.curentPage = 1
			this.pageSize = pageSize
			this.getTableData();
		},
	
		//获取列表数据
		getTableData() {
			let para = {
				"currentPage": this.currentPage,
				"pageSize": this.pageSize,
				"keyword": this.keyword
			};
			this.listLoading = true; //显示加载圈
			//分页查询
			this.$http.post("/permission/page", para).then(result => {
			console.log(result.data.data.total);
				console.log(result.data.data.list);
			 
				this.totals = result.data.data.total;
				this.tableDatas = result.data.data.list;
				this.listLoading = false;  //关闭加载圈
			});
		},
	},
	mounted() {
		this.getTableData();
	}
}

</script>

<style scoped></style>
